package com.qf.controller;

import com.qf.pojo.BaseResp;
import com.qf.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/shop")
public class ShopController {

    @Autowired
    ShopService shopService;

    @RequestMapping("/findAllShop")
    public BaseResp findAllShop(){
        return shopService.findAll();
    }

    @RequestMapping(value = "/findById",method = RequestMethod.POST)
    public BaseResp findById(@RequestBody Map map){
        return shopService.findById(Integer.valueOf(map.get("id").toString()));
    }

    @RequestMapping(value = "/myLike",method = RequestMethod.POST)
    public BaseResp addMyLike(@RequestBody Map map ,HttpServletRequest request){
        return shopService.addMyLike(Integer.valueOf(map.get("id").toString()),request);
    }

    @RequestMapping(value = "/findAllMyLike")
    public BaseResp addMyLike(HttpServletRequest request){
        return shopService.findMyLike(request);
    }

    @RequestMapping(value = "/deleteMylike",method = RequestMethod.POST)
    public BaseResp deleteMylike(@RequestBody Map map,HttpServletRequest request){
        return shopService.deleteMylike(map.get("id").toString(),request);
    }

    @RequestMapping(value = "/deleteAllMylike",method =RequestMethod.POST )
    public BaseResp deleteAllMylike(@RequestBody Map map,HttpServletRequest request){
        return shopService.deleteAllMylike(map.get("idlist").toString(),request);
    }

    @RequestMapping(value = "/findCollect",method =RequestMethod.POST )
    public BaseResp findCollect(@RequestBody Map map,HttpServletRequest request){
        return shopService.findCollect(map.get("id").toString(),request);
    }



    @RequestMapping(value = "/addShopCart",method = RequestMethod.POST)
    public BaseResp addShopCart(@RequestBody Map map,HttpServletRequest request){
        return shopService.addShopCart(Integer.valueOf(map.get("id").toString()),Integer.valueOf(map.get("number").toString()),request);
    }


}
